
"""
@author: xiangping
@contact: xiangpingbu@gmail.com
@time: 2020/1/4 5:06 下午
@file: __init__.py.py
@Desc:
"""
import pandas as pd
from sklearn.ensemble import AdaBoostRegressor
import pickle

from sklearn.linear_model import LinearRegression


def long():
    # data = pd.read_csv("/Users/lifeng/Downloads/long.csv")
    data = pd.read_csv("/Users/lifeng/Downloads/9.2日修正版/长期模型训练.csv")

    x_train = data.iloc[:26000, 2:]
    x_test = data.iloc[26001:, 2:]
    y_train = data.iloc[:26000, 1]
    y_test = data.iloc[26001:, 1]
    print(x_train.columns)

    fit1 = LinearRegression()
    fit1.fit(x_train, y_train)

    pickle.dump(fit1, open('./lugang_activiness_long.pkl','wb'))


def short():
    import pandas as pd
    import numpy as np
    from sklearn import preprocessing
    from sklearn.neural_network import MLPRegressor
    from sklearn.neural_network import MLPClassifier
    from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
    from sklearn.linear_model import LinearRegression

    # data = pd.read_csv("/Users/lifeng/Downloads/9.2日修正版/短期模型训练.csv")
    data = pd.read_csv("/home/lifeng/下载/9.2日修正版/短期模型训练.csv")

    x_train = data.iloc[:2600, 2:]
    x_test = data.iloc[2601:, 2:]
    y_train = data.iloc[:2600, 1]
    y_test = data.iloc[2601:, 1]

    fit1 = LinearRegression()
    fit1.fit(x_train, y_train)
    print(x_train.columns)

    pred1_train = fit1.predict(x_test)
    predict = pd.DataFrame(pred1_train)
    predict.index = y_test.index

    pickle.dump(fit1, open('./lugang_activiness_short.pkl', 'wb'))

if __name__ == "__main__":
    short()